<?php
/**
 * Created by PhpStorm OF Administrator.
 * User: YUYI
 * Date: 2018/7/2 0002
 * Time: 下午 4:03
 * Administrator
 */

namespace app\common\model;


use think\model\relation\BelongsTo;

class AccountBook extends BaseModel
{
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'createTime';
    protected $updateTime = false;
    /**
     * 將金額單位由分變為元
     * @param $value
     * @return string
     */
    public function getAmountAttr($value)
    {
        return ($value/100).'元';
    }

    /**
     * 將金額單位由元變成分
     * @param $value
     * @return int
     */
    public function setAmountAttr($value)
    {
        return $value*100;
    }

    /**
     * 關聯查找銀行卡信息
     * @return BelongsTo
     */
    public function getBankList()
    {
        return $this->belongsTo('BankList','bid','id')->setEagerlyType(0);
    }
}